<template>
  <div>
        <!-- <el-popover placement="bottom-start" width="1000" style="margin-right:10px;" trigger="click">
          <el-form :inline="true" :model="search">
              <el-form-item label="编码" >
                  <el-input v-model="searchTop.code29" clearable></el-input>
              </el-form-item>            
              <el-button type="primary" @click="searchTopBtn">确认</el-button>
          </el-form>
          <el-button slot="reference" type="primary" icon="el-icon-search">查询</el-button>
        </el-popover> -->
      <el-table :data="tableList" stripe border class="user-table"    style="width: 100%;">
          <el-table-column prop="group.name" label="所属库" sortable min-width="100"></el-table-column>
          <el-table-column prop="name" label="名称" sortable min-width="100"></el-table-column>
          <el-table-column prop="code" label="编码" sortable min-width="100"></el-table-column>
          <el-table-column prop="diameter" label="直径" sortable min-width="100"></el-table-column>
          <el-table-column prop="depth" label="深度" sortable min-width="100"></el-table-column>
          <el-table-column prop="blade" label="刃长" sortable min-width="100"></el-table-column>
          <el-table-column prop="mo" label="磨" sortable min-width="100"></el-table-column>
          <el-table-column prop="remark" label="备注" sortable min-width="100"></el-table-column>
          <el-table-column label="操作">
            <template slot-scope="scope">
              <el-button type="text" @click="showDialog(scope.row)">已采购</el-button>
            </template>
          </el-table-column>
        </el-table>   
        <el-pagination  @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="currentPage" :page-sizes="[5,10, 15,20, 25,30,50, 100]" :page-size="pagesize" layout="total, sizes, prev, pager, next, jumper" :total="total"></el-pagination>

  </div>
</template>
<script>
import planApi from 'plugins/axios/planApi.js';
import baseApi from 'plugins/axios/baseApi.js';
export default {
  components: {

  },
  data(){
    return {
      search:{},
      tableList:[],
      currentPage: 1,
      pagesize: 10,
      total:0,
      state:0,
      isSxpc:sessionStorage.getItem('ROLE_sxpc'),//当前用户是否拥有数铣排程权限
      isPtxf:sessionStorage.getItem('ROLE_ptxf'),//当前用户是否拥有任务下发权限
      dialog:{
        isShow:false,
        title:'',
        currentRow:'',
      },
    }
  },
  mounted(){
    
  },
  created(){
    this.$nextTick(()=>{
          this.queryTableList();
    });
  },
  watch: {
  },
  methods:{
    searchBtn(){
      let self = this;
      self.queryTableCheckList();
    },
    showDialog(row){
      let self = this;
      self.editNeedBuy(row);
    },
    queryTableList(){
      let self = this;
      let param = {
        currentPage:self.currentPage,
        pageSize:self.pagesize,
        state:self.state,
      }  
      planApi.queryNeedBuyByCondition(param).then(res=>{
          self.tableList = res.content.records;
          self.total = res.content.total;
      });
    },
    editNeedBuy(row){
      let self = this;
      let param = {
        id:row.id,
        state:1,
      }
      planApi.editProductionNeedBuyByCondition(param).then(res=>{
        self.$message({message:'操作成功',type:'success'});
        self.queryTableList();
      });
    },
    handleSizeChange(size) {
      this.pagesize = size;
      this.queryTableList();
    },
    handleCurrentChange(currentPage) {
      this.currentPage = currentPage;
      this.queryTableList();
    },
  }
}
</script>
<style lang="stylus" scoped>
  .addRole
    padding-bottom 10px
  .content-rowspan div
    padding-left: 13px;
    line-height: 46px;
    border-bottom: 1px solid #ECEDEE;
    &:last-child
      border-bottom:none
</style>